/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aal.model;

import com.aal.business.EmployeeManagementLocal;
import com.aal.entity.Employee;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author quy
 */
public class EmployeeManagement {

    EmployeeManagementLocal employeeManagement = lookupEmployeeManagementLocal();
    private String username;
    private String password;
    private String firstname;
    private String lastname;
    private String email;
    private String phone;
    
    private boolean gender;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public boolean getGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public boolean getCreateuser() {
        return employeeManagement.createUser(username, password, firstname, lastname, email, phone, gender);
    }
    public boolean getEdituser(){
        return employeeManagement.editUser(username, password, firstname, lastname, email, phone, gender);
    }
    public List<Employee> getSearchemployee(){
        return employeeManagement.searchEmployee(username);
    }
    public boolean loginOk(){
        return employeeManagement.loginOk(username, password);
    }
    private EmployeeManagementLocal lookupEmployeeManagementLocal() {
        try {
            Context c = new InitialContext();
            return (EmployeeManagementLocal) c.lookup("java:global/AAL/AAL-ejb/EmployeeManagement!com.aal.business.EmployeeManagementLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
